<template>
  <el-container id="layout_app">
    <el-aside width="200px">
      <p>小U商城后台</p>
      <el-menu
        default-active="2"
        class="el-menu-vertical-demo"
        background-color="rgb(51, 51, 51)"
        text-color="#fff"
        router
      >
        <el-menu-item index="1">
          <i class="el-icon-menu"></i>
          <span slot="title"> 管理中心</span>
        </el-menu-item>
        <el-submenu index="2">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span> 系统设置</span>
          </template>
          <el-menu-item-group>
              <el-menu-item index="/menu">菜单管理</el-menu-item>
            <el-menu-item index="/role">角色管理</el-menu-item>
            <el-menu-item index="/admin">管理员管理</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-submenu index="3">
          <template slot="title">
            <i class="el-icon-s-goods"></i>
            <span> 商城管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="/sort">商品分类</el-menu-item>
            <el-menu-item index="3-2">商品规格</el-menu-item>
            <el-menu-item index="3-3">商品管理</el-menu-item>
            <el-menu-item index="3-4">会员管理</el-menu-item>
            <el-menu-item index="3-5">轮播图管理</el-menu-item>
            <el-menu-item index="3-6">秒杀活动</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header>
        <el-button type="primary" icon="el-icon-s-fold" size="mini"></el-button>
        <!-- 面包屑 -->
        <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{ path: '/' }">管理中心</el-breadcrumb-item>
          <el-breadcrumb-item><a href="/">菜单管理</a></el-breadcrumb-item>
        </el-breadcrumb>
        <!-- 按钮 -->
        <el-button icon="el-icon-back" circle size="mini"></el-button>
        <!-- 下拉菜单 -->
        <el-dropdown @command="handleCommand">
          <span class="el-dropdown-link">
            <i class="el-icon-arrow-down el-icon--right"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="a">个人信息</el-dropdown-item>
            <el-dropdown-item command="b">全屏预览</el-dropdown-item>
            <el-dropdown-item command="logOut">安全退出</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </el-header>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  methods: {
    handleCommand(command) {
      if (command == "logOut") {
        localStorage.removeItem("userData");
        this.$router.push("/login");
      }
    },
  },
};
</script>

<style scoped>
#layout_app {
  width: 100%;
  height: 100vh;
}
.el-header {
  background-color: #fff;
  color: #333;
  line-height: 60px;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  /* 改过 */
  line-height: 60px;
  background-color: #444;
  color: white;
  font-weight: 400 !important;
  letter-spacing: 4px;
  font-size: 20px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  /* text-align: center; */
  /* line-height: 160px; */
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
/* 修改侧面导航高度 */
.el-menu {
  height: calc(100vh - 66px);
  /* width: 206px; */
}
/* 修改面包屑 */
.el-breadcrumb {
  display: inline-block;
}
/* 下拉菜单 */
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-dropdown {
  font-size: 12px;
  position: absolute;
  right: 20px;
}
</style>